//
//  QSAddVisitSuccessViewController.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/30.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "QSAddVisitSuccessViewController.h"

@interface QSAddVisitSuccessViewController ()
/** 已完成图片*/
@property (nonatomic, strong)UIImageView *successImageView;
/** 已完成Label*/
@property (nonatomic, strong)UILabel *successLabel;
/** 返回首页按钮*/
@property (nonatomic, strong)UIButton *backHomeButton;
@end

@implementation QSAddVisitSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"新增走访";
    UIBarButtonItem *backBtn = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"ic_navigation_back"] target:self action:@selector(backHomeAction:)];
    
    self.navigationItem.leftBarButtonItem = backBtn;
    
    [self configSubView];
}

- (void)configSubView{
    [self.view addSubview:self.successImageView];
    [self.view addSubview:self.successLabel];
    [self.view addSubview:self.backHomeButton];
 
    
    [_successImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).offset(kRealValue(57));
        make.width.offset(kRealValue(136));
        make.height.offset(kRealValue(128));
    }];
    [_successLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(_successImageView.mas_bottom).offset(kRealValue(18));
    }];
    [_backHomeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(kRealValue(65));
        make.right.equalTo(self.view).offset(- kRealValue(65));
        make.top.equalTo(_successLabel.mas_bottom).offset(kRealValue(78));
        make.height.offset(kRealValue(44));
    }];
}


- (UIImageView *)successImageView{
    if (!_successImageView) {
        _successImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ic_signSuccess"]];
    }
    return _successImageView;
}

- (UILabel *)successLabel{
    if (!_successLabel) {
        _successLabel = [UILabel labelWithName:@"走访记录提交成功!\n别忘记去签到哦！!" font:[UIFont QSFontOfSize16] textColor:[UIColor QSColorBlack666666] textAlignment:NSTextAlignmentCenter];
        _successLabel.numberOfLines = 0;
    }
    return _successLabel;
}

- (UIButton *)backHomeButton{
    if (!_backHomeButton) {
        _backHomeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _backHomeButton.backgroundColor = [UIColor colorWithHexString:@"#128BEC"];
        [_backHomeButton setTitleColor:[UIColor QSColorWhiteFFFFFF] forState:UIControlStateNormal];
        [_backHomeButton setTitle:@"返回首页" forState:UIControlStateNormal];
        [_backHomeButton.titleLabel setFont:[UIFont QSFontOfSize16]];
        _backHomeButton.layer.cornerRadius = 22;
        [_backHomeButton addTarget:self action:@selector(backHomeAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return  _backHomeButton;
}

- (void)backHomeAction:(UIButton *)sender{
    if ([[UIViewController currentViewController] isKindOfClass:NSClassFromString(@"QSMainTabBarController")]) {
        return;
    }
    [UIApplication sharedApplication].keyWindow.rootViewController = [[QSMainTabBarController alloc] init];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
